/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "Creator.h"

namespace liba
{
namespace input
{
namespace hard
{
namespace windows
{

static Keyboard * keyboard = 0;
static Mouse * mouse = 0;

Creator::Creator(bool init_keyboard, bool init_mouse)
{
	if( keyboard || mouse )
		throw Gluck(__FUNCTION__, "keyboard or mouse already exist");
	
	if(init_keyboard)
		keyboard = new Keyboard;
	
	if(init_mouse)
		mouse = new Mouse;
	
	RECT rect;
	GetClientRect( get_window()->get_wnd(), &rect );
	resize( rect.bottom - rect.top, rect.right - rect.left );
}

Creator::~Creator()
{
	delete mouse; mouse = 0;
	delete keyboard; keyboard = 0;
}

void Creator::mouse_up(int key )
{
	if(mouse)
		mouse->mouse_up( key );
}
void Creator::mouse_move(int x, int y)
{
	if(mouse)
		mouse->mouse_move( x, y );
}
void Creator::mouse_down(int key )
{
	if(mouse)
		mouse->mouse_down( key );
}
void Creator::key_up(int scan_code)
{
	if(keyboard)
		keyboard->key_up( scan_code );
}
void Creator::key_down(int scan_code)
{
	if(keyboard)
		keyboard->key_down( scan_code );
}
void Creator::key_char(wchar_t letter)
{
	if(keyboard)
		keyboard->key_char( letter );
}

void Creator::resize(int height, int width)
{
	if(mouse)
		mouse->resize(height, width);
}

} // namespace windows
} // namespace hard
} // namespace input
} // namespace liba


